/** 
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
* 
* MpmDataBoardCustomizeRecordServiceAuto
* 数据看板自定义记录表
* 
* 修改纪录
* 2020-12-29 版本：1.0 wudaliang 创建。
* @version 版本：1.0
* @author 作者：wudaliang
* 创建日期：2020-12-29
*/

package com.topscomm.mpm.service.impl.auto;

import com.topscomm.cbo.pojo.CboOrgEntity;
import com.topscomm.cbo.pojo.CboRoleEntity;
import com.topscomm.cbo.service.impl.CboOrgService;
import com.topscomm.cbo.service.impl.CboRoleService;
import com.topscomm.mpm.pojo.MpmDataBoardComponentAchivesEntity;
import com.topscomm.mpm.service.impl.MpmDataBoardComponentAchivesService;
import com.topscomm.pub.util.StringBufferProxy;
import java.util.List;
import javax.annotation.Resource;
import com.topscomm.basic.IBasicDao;
import com.topscomm.tap.common.DatacodeCache;
import java.util.Map;
import com.topscomm.mpm.*;
import com.topscomm.mpm.pojo.MpmDataBoardCustomizeRecordEntity;
import com.topscomm.mpm.dao.IMpmDataBoardCustomizeRecordDao;
import org.springframework.beans.factory.annotation.Autowired;


public class MpmDataBoardCustomizeRecordServiceAuto extends MpmService<MpmDataBoardCustomizeRecordEntity,IMpmDataBoardCustomizeRecordDao> {


	@Autowired
	private MpmDataBoardComponentAchivesService mpmDataBoardComponentAchivesService;

	@Autowired
	private CboOrgService cboOrgService;

	@Autowired
	private CboRoleService cboRoleService;

	/**
	 * @author: wudaliang
	 * @date: 2020-12-29
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("recordlevel") != null) {
			temp = mapRow.get("recordlevel").toString();
			mapRow.put("disprecordlevel", datacodeCache.getValueDynamic("MpmRecordLevel", temp, "code", "name"));
		}
		if (mapRow.get("position") != null) {
			temp = mapRow.get("position").toString();
			mapRow.put("dispposition", datacodeCache.getValueDynamic("MpmPosition", temp, "code", "name"));
		}
		if (mapRow.get("componentid") != null) {
			temp = mapRow.get("componentid").toString();
			MpmDataBoardComponentAchivesEntity entity = mpmDataBoardComponentAchivesService
				.queryById(temp);
			mapRow.put("dispcomponentid", entity.getName());
			mapRow.put("component",entity.getName());
		}
		if (mapRow.get("orgcode") != null) {
			temp = mapRow.get("orgcode").toString();
			StringBufferProxy wheresql = new StringBufferProxy();
			wheresql.appendSingle("1=1");
			wheresql.appendSingle("and code = '{0}'",temp);
			List<CboOrgEntity> cboOrgEntities = cboOrgService.queryByWhere(wheresql.toString());
			mapRow.put("disporgcode", cboOrgEntities.get(0).getName());
			mapRow.put("orgname", cboOrgEntities.get(0).getName());
		}
		if (mapRow.get("rolecode") != null) {
			temp = mapRow.get("rolecode").toString();
			StringBufferProxy wheresql = new StringBufferProxy();
			wheresql.appendSingle("1=1");
			wheresql.appendSingle("and code = '{0}' ",temp);
			List<CboRoleEntity> cboRoleEntities = cboRoleService.queryByWhere(wheresql.toString());
			mapRow.put("disprolecode",cboRoleEntities.get(0).getName());
			mapRow.put("rolename",cboRoleEntities.get(0).getName());
		}
	}

	@Override
	@Resource(name = "mpmDataBoardCustomizeRecordDao")
	public void setDao(IBasicDao<MpmDataBoardCustomizeRecordEntity> dao) {		
		super.setDao(dao);
	}
}
